﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using MySql.Data.MySqlClient;
using Cinemon.MySqlConnect;
public partial class Schedules_add : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == true && TextBox1.Text != "")
        {
            using (DatabaseManager manager = new DatabaseManager())
            {
                List<MySqlParameter> param = new List<MySqlParameter> {
				new MySqlParameter("roomid", RoomDrop.SelectedValue),
				new MySqlParameter("movieid", movieDrop.SelectedValue),
				new MySqlParameter("sDate", Calendar1.SelectedDate.ToString()),
				new MySqlParameter("startT", TextBox1.Text),
                new MySqlParameter("endT", TextBox2.Text)
			};

                manager.ExecuteNonQuery("InsertShow", param);
            }
            Response.Redirect("view.aspx");
            
        }
        Calendar1.SelectedDate = DateTime.Today;
        using (DatabaseManager manager = new DatabaseManager())
        {
           
            movieDrop.DataSource = manager.ExecuteQuery("GetAllMovies");
            movieDrop.DataTextField = "Movie Name";
            movieDrop.DataValueField = "Movie ID";
            movieDrop.DataBind();

            RoomDrop.DataSource = manager.ExecuteQuery("GetAllRooms");
            RoomDrop.DataTextField = "Isles";
            RoomDrop.DataValueField = "Room NUmber";
            RoomDrop.DataBind();
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("view.aspx");
    }
}